<?php
/*
 * Author : pandiam & basanas
 */
require_once ('include/css_head.php');
require_once ('include/functions.php');
require_once ('include/header.php');
?>
<div style="width: 245px;" id="sidebar"></div>
<div id="content"></div>

<script type="text/javascript">
$.ajaxSetup ({ cache: false });
var ajax_load = "<img src='images/load.gif' alt='loading...' />";
$("#sidebar").load($("#sidebar").html(ajax_load).load('sidebar.php'));
</script>

<?php
$query = trim($_POST['search_query'], " ");
if (!empty($query) && $query != " ")
    $query2 = str_replace(" ", "+", $query);
else
    $query2 = "+";

// For the welcome page
$_SESSION['search_query'] = "";

echo "<script type=\"text/javascript\">";
echo " $.ajaxSetup ({ cache: false });";
echo " var ajax_load = \"<img class='loading' src='images/load.gif' alt='loading...' />\" ;";
echo " var loadUrl = \"results.php?query=";
echo $query2;
if (empty($_POST['filt_categories']) && empty($_POST['filt_categories2']))
    echo "&filter=error\";";
else
    if (!empty($_POST['filt_categories']) && empty($_POST['filt_categories2']))
        echo "&filter=categories\";";
    else
        if (empty($_POST['filt_categories']) && !empty($_POST['filt_categories2']))
            echo "&filter=entities\";";
        else
            echo "&filter=both\";";
echo "$(\"#content\").load($(\"#content\").html(ajax_load).load(loadUrl));";
echo "</script>";

require_once ('include/footer.php');
?>